from apps.common.base.views import *
from apps.user.serializers import *
from apps.user.dao import UserDao
from apps.user.filters import UserFilter

def getAllUsers(self):
    _list = UserDao().findAll().filter((Q(role='custom')))
    _list = _list.select_related('parent', 'rank', 'role', 'team', 'identity').prefetch_related('user_ActivityPerformance')
    return _list

def getAllAdmin(self):
    _list = UserDao().findAll().exclude(Q(role='custom') | Q(role__isnull=True))
    _list = _list.select_related('role')
    return _list

class BaseUserViewSet(BaseViewSet):
    serializer_class = UserModelSerializer
    filter_class = UserFilter
    DAO_CLASS = UserDao

